<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function sum() {
        console.log(arguments); //返回实参列表的一个伪数组。
        console.log(arguments.length); //获取实参个数
        console.log(arguments[0]); //获取第一个实参*/
        var result = 0;
        for (var i = 0; i < arguments.length; i++) {
          //console.log(arguments[i]);//通过arguments实现累加和
          result += arguments[i];
        }
        return result;
      }

      console.log(sum(1, 2, 3));
      console.log(sum(1, 2, 3, 4));
    </script>
  </body>
</html>
